import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import layout from '../views/layout/index.vue'
import user from '../views/layout/user'


const routes = [
  {
    path: '/layout',
    name: 'layout',
    component: layout,
    // 子路由
    children: [
      { // user需要登录才可以访问，给user添加一个标签，然后导航守卫
        path: '/user',
        component: user,
        // component: () => import('../views/layout/user.vue')
        meta: { // 给user添加一个标签
          needLogin: true,
          needUser: true
        }
      },
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router




